﻿<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>前锋图书管理系统</title>
    <link rel="stylesheet" href="/css/public.css"/>
    <link rel="stylesheet" href="/css/style.css"/>
</head>
<style>
        html,body{
        width: 100%;
        height: 100%;
    }
    .homeWrap{
        width: 100%;height: 100%;
        padding-top: 76px;position: relative;box-sizing: border-box;overflow: hidden;
    }
    .homeWrap div{box-sizing: border-box;}
    .publicMian,.left{height: 100%;}
    .homeHeader{width: 100%; position: absolute;left: 0;top: 0;}
</style>
<body style="line-height: 24px;font: 14px Helvetica Neue,Helvetica,PingFang SC,\5FAE\8F6F\96C5\9ED1,Tahoma,Arial,sans-serif;">
<!--头部-->
<div class="homeWrap">
    <div class="homeHeader">
        <header class="publicHeader">
            <h1>前锋图书管理系统</h1>
            <div class="publicHeaderR">
                <p><span>下午好！</span><span style="color: #fff21b"> Admin</span> , 欢迎你！</p>
                <a href="/admin/index/signOut">退出</a>
            </div>
        </header>

    <!--时间-->
        <section class="publicTime">
            <span id="time">2015年1月1日 11:11  星期一</span>
        </section>
    </div>
<!--主体内容-->
    <section class="publicMian ">
        <div class="left">
            <h2 class="leftH2"><span class="span1"></span>功能列表 <span></span></h2>
            <nav>
                <ul class="list">
                    <li><a href="/admin/home/home">首页</a></li>
                    <li><a href="/admin/home/borrowingmanagement">借阅管理</a></li>
                    <li><a href="/admin/home/bookrecord">图书记录</a></li>
                    <li><a href="/admin/home/bookadd">图书添加</a></li>
                    <li id="active"><a href="/admin/scrollmember/scroll">滚屏</a></li>
                    <li><a href="/admin/scrollmember/member">会员管理</a></li>
                    <li><a href="/admin/home/editpass">修改密码</a></li>
                    <li><a href="/admin/home/groupbuy">团队来源</a></li>
                </ul>
            </nav>
        </div>
        <div class="right">
            <div class="location">
                <strong>你现在所在的位置是:</strong>
                <span>滚屏</span>
            </div>
            <div class="search">
                <input type="button" value="添加" onclick="addScroll()" style="float: right;margin-top: 10px;background: #47acf1;"/>
            </div>
            <div class="scrollList">

            </div>
        </div>
        <div class="pagePage" style="top:670px;">
            <div class="page_control">
                <div class="pagination"></div>
            </div>
        </div>
    </section>
</div>
<script src="/js/jquery.js"></script>
<script src="/js/js.js"></script>
<script src="/js/time.js"></script>
<script src="/js/layer/layer.js"></script>
<script src="/js/jquery.paging.js"></script>

<script>
    // 点击添加按钮出弹窗
    function addScroll(){
        layer.open({
            type: 1,
            title: '添加滚屏',
            area: ['413px', '242px', '-116.5px', '334.5px'],
            shadeClose: true, //点击遮罩关闭
            content:'<div class="remove" style="width: 412px;">' +
            '<div class="removerChid">' +
            '<div class="removeMain">' +
            '<div class="search" style="background: #ffffff;padding-left: 0;">' +
            '<span>滚屏内容：</span>' +
            '<input type="text" placeholder="请输入滚屏内容" id="useraccounts" class="oldPassword"/>' +
            '</div>' +
            '<div class="search" style="background: #ffffff;padding-left: 0;">' +
            '<input type="button" value="添加" onclick="confirmAndRefresh()" style="width: 248px;background: #47acf1;"/>'+
            '</div>' +
            '</div>' +
            '</div>' +
            '</div>'
        });
    }

    // 确认并刷新
    function confirmAndRefresh(){
        var txt = $(".oldPassword").val();
        if(txt==''){
            layer.msg('还没填写不能确认滚屏');
        }
        else{
            $.ajax({
                url:'/admin/Scrollmember/scroll',
                type:'POST',
                data:{
                    txt:txt,
                },
                success:function(res){
                    if(res == 1){
                        layer.msg('添加滚屏成功');
                        window.location.href = '/admin/scrollmember/scroll';
                    }
                    else{
                        layer.msg('添加滚屏失败');
                        // window.location.href = '/admin/scrollmember/scroll';
                    }
                },
            });
        }
    }

    // 时间戳转换成日期
    function unix_to_datetime(unix) {
        var now = new Date(parseInt(unix) * 1000);
        return now.toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");
    }
    // 分页展示
    $('.pagination').paging({
        total: '',
        currentPage: '',
        showPage: 5,        //显示的页数
        animation: false,
        showJump: false,
        ajaxSubmitType: 'post',
        simpleType: 1,
        url: '/admin/Scrollmember/allHorn',
        idParameter: "page",
        ajaxData: {'pageSize': 1},
        beforeAjaxSubmit: function () {
            PageAPI.AddAjaxData({"pageSize": $(".pageSize").val()});
        },
        ajaxSubmitBack: function (data) {
            console.log(data);
            $('.userlist').empty();
            var orderinfo = data.data;
            if(orderinfo=='' ||orderinfo==undefined){
                $(".userlist").html(' <h2 style="text-align: center;padding-top:120px;height: 166px;color: red;">暂无数据</h2>');
                $(".pagination").hide();
            }else{
                $(".pagination").show();
                var infohtml='';
                infohtml += '<table class="providerTable" cellpadding="0" cellspacing="0">\n'
                infohtml += '<tr class="firstTr">'
                infohtml += '<th width="10%">编号</th>'
                infohtml += '<th width="20%">内容</th>'
                infohtml += '<th width="15%">开始时间</th>'
                infohtml += '<th width="15%">预计结束时间</th>'
                infohtml += '<th width="15%">结束时间</th>'
                infohtml += '<th width="10%">滚屏状态</th>'
                infohtml += '<th width="20%">操作</th>'
                infohtml += '</tr>'
                $.each(orderinfo,function(index,value){
                    infohtml += '<tr>'
                    infohtml += '<td>'+value['id']+'</td>'
                    infohtml += '<td>'+value['content']+'</td>'
                    if(value['starttime'] != '' || value['starttime'] != null){
                        infohtml += '<td>'+unix_to_datetime(value['starttime'])+'</td>'
                    }
                    else{
                        infohtml += '<td></td>'
                    }
                    if(value['expectStoptime'] != '' || value['expectStoptime'] != null){
                        infohtml += '<td>'+unix_to_datetime(value['expectStoptime'])+'</td>'
                    }
                    else{
                        infohtml += '<td></td>'
                    }
                    if(value['stoptime'] != '' || value['stoptime'] != null){
                        infohtml += '<td>'+unix_to_datetime(value['stoptime'])+'</td>'
                    }
                    else{
                        infohtml += '<td></td>'
                    }
                    if(value['isdelete'] == 0) {
                        if (value['isScroll'] == 0) {
                            infohtml += '<td><span style="color: #9ac70f">已停止滚屏</span></td>'
                            infohtml += '<td>'
                            infohtml += '<input type="button" onclick="deleteScroll('+value['id']+')" value="删除滚屏" class="anniu" style="width: 70px"/>';
                            infohtml += '</td>'
                        }
                        else if (value['isScroll'] == 1) {
                            infohtml += '<td>正在滚动中</td>'
                            infohtml += '<td>'
                            // infohtml += '<input type="button" onclick="stopScroll('+value['id']+')" value="停止滚屏" class="anniu" style="width: 70px"/>';
                            infohtml += '<input type="button" onclick="deleteScroll('+value['id']+')" value="删除滚屏" class="anniu" style="width: 70px"/>';
                            infohtml += '</td>'
                        }

                    }
                    else{
                        infohtml += '<td><span style="color:red;">已删除</span></td>'
                    }

                    infohtml += '</tr>'
                })
                infohtml+='</table>';
                $('.scrollList').html(infohtml);
            }
        },
        ajaxFormatBack: function (data) {
            data.total = data.totalpage;
            data.currentPage = data.currentPage;
        }
    });

    // 删除滚屏
    function deleteScroll(id){
        $.ajax({
            url:'/admin/Scrollmember/deleteScroll',
            type:'POST',
            data:{
                id:id,
            },
            success:function(res) {
                if (res == 1) {
                    layer.msg('删除滚屏成功');
                    window.location.href = '/admin/scrollmember/scroll';
                }
                else {
                    layer.msg('删除滚屏失败');
                }
            }
        });
    }

    // 停止滚屏
    // function stopScroll(id){
    //     $.ajax({
    //         url:'/admin/Scrollmember/stopScroll',
    //         type:'POST',
    //         data:{
    //             id:id,
    //         },
    //         success:function(res) {
    //             if (res == 1) {
    //                 layer.msg('滚屏已停止');
    //                 window.location.href = '/admin/scrollmember/scroll';
    //             }
    //             else {
    //                 layer.msg('滚屏停止失败');
    //             }
    //         }
    //     });
    // }
</script>

</body>
</html>